package com.quydat.forum.beans;

import java.util.List;

import com.quydat.forum.entites.CategoryEntity;
import com.quydat.forum.interfaces.CategoryEntityManageLocal;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 * Session Bean implementation class CategoryEntityManage
 */
@Stateless(mappedName = "CategoryEntityManage")
@LocalBean
public class CategoryEntityManage implements CategoryEntityManageLocal {
	/**
	* Injecting the persistence context.
	 */
	@PersistenceContext(unitName = "forum")
	private EntityManager em;
    /**
     * Default constructor. 
     */
    public CategoryEntityManage() {
        // TODO Auto-generated constructor stub
    }

	@SuppressWarnings("unchecked")
	@Override
	public List<CategoryEntity> getAllCategory() {
		Query query=em.createNamedQuery(CategoryEntity.findAll);
		return query.getResultList();
	}

}
